Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.7K
Visualizações
"COPY failed: no source files were specified" when Dockerfile is not in root directory on Docker Hub

When I run my application through docker-compose up, it builds and runs without any issues. When I try to host it on Docker Hub, it fails to build with the error COPY failed: no source files were specified. I believe it is because the Dockerfile is not in the root directory.

My folder structure is like this:

root
-- docker-compose.yml
-- app
   -- Dockerfile
   -- package.json
   -- package-lock.json
   -- src
      -- .....

My Dockerfile is below, and when I run docker-compose up (which points to the Dockerfile within /app) it runs fine:

FROM node:8.10.0-alpine
WORKDIR /usr/src/app
COPY package*.json /usr/src/app/
RUN npm install --production
COPY . /usr/src/app
EXPOSE 4000
CMD ["npm", "run", "app"]

I am wanting to host my project on Docker Hub, but I'm getting the following error:

Step 1/7 : FROM node:8.10.0-alpine
---> adc4b0f5bc53
Step 2/7 : WORKDIR /usr/src/app
Removing intermediate container 743246352cea
---> 3dcb720d4618
Step 3/7 : COPY package*.json /usr/src/app/
COPY failed: no source files were specified

The build rules I've set to point to the correct Dockerfile location is below:

Docker Hub build rules showing Dockerfile location as app/Dockerfile

Is my Dockerfile wrong, or am I not configuring Docker Hub correctly when I try to hook it up to my GitHub repo?

For context, the GitHub repo is here.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In the build configuration, you need to configure the "build context" directory rather than changing the Dockerfile location. Otherwise, the build will run in the parent of your github repo where the package*.json files do not exist. Note the column after "Dockerfile location" when configuring automated builds in the example below:

enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda